package ex2.LinkedBinaryTree;

import week6.PostfixEvaluator;

import java.util.Iterator;
import java.util.Scanner;

public class PrefixToPostfixTester {
    public static void main(String[] args) {
        String expression, again;
        String result;
        int result1;
        LinkedBinaryTree tree;

        Scanner in = new Scanner(System.in);

        do
        {
            PrefixToPostfix evaluator = new PrefixToPostfix();
            System.out.println("输入中缀表达式: ");
            expression = in.nextLine();

            result = evaluator.convert(expression);

            System.out.println(result);

            System.out.println("输出中缀树：");
            System.out.println(evaluator.getTree());

            PostfixEvaluator evaluator1 = new PostfixEvaluator();

            result1 = evaluator1.evaluate(result);

            System.out.println("计算结果："  + result1);

            System.out.print("Evaluate another expression [Y/N]? ");
            again = in.nextLine();
            System.out.println();
        }
        while (again.equalsIgnoreCase("y"));
    }
}
